package com.guigu.xm.lq.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.xm.lq.mapper.SysUserRoleMapper;
import com.guigu.xm.lq.service.SysUserRoleService;
import com.guigu.xm.pojo.PageVo;
import com.guigu.xm.pojo.SysUserRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserRoleServiceImpl implements SysUserRoleService {
    @Autowired(required = false)
    SysUserRoleMapper sur;

    @Override
    public int insert(SysUserRole record) {
        return sur.insert(record);
    }

    @Override
    public int updateRole(String id, String descn) {
        return sur.updateRole(id, descn);
    }

    @Override
    public PageVo<SysUserRole> chaUser(String login_id, String name, String page, String num) {
        login_id=login_id==null?"":login_id;
        name=name==null?"":name;
        page=page==null?"1":page;
        num=num==null?"2":num;
        PageHelper.startPage(Integer.parseInt(page),Integer.parseInt(num));
        List<SysUserRole> sysUserRoles = sur.QueryUser(login_id, name);
        PageInfo pageInfo=new PageInfo(sysUserRoles);
        PageVo pageVo=new PageVo();
        pageVo.setTotal(pageInfo.getTotal());
        pageVo.setRows(sysUserRoles);
        return pageVo ;
    }
}
